?><?
class cls_search extends cls_entity{

  function entity(){
    return "search";
  }

  function search($string){
    $bases=bases_from_string($string);
    $classes=get_entity("cls_classes");
    $fields="";
    foreach($classes->all_attributes() as $attribute){
      $name=$attribute->name;
      $type=$attribute->type;
      if(strpos($type,"varchar")!==false||strpos($type,"text")!==false){
        $fields.=($fields==""?"":", ").$name;
      }
    }
    $search="";
    foreach($bases as $base=>$count){
      $search.="$base* ";
    }
    $sql=
      "SELECT instance_id,title, MATCH($fields) ".
      "AGAINST ('$search'  IN BOOLEAN MODE) as rel ".
      "FROM instance ".
      "WHERE class_name='article' ".
      "ORDER BY rel desc ";


  }

}